<tagLib name="html" />
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>积分兑换购物卡</title>
	<include file="Public:header" />
	<style type="text/css">
		.input{width:190px; border:1px solid #ccc; padding:2px;}
		.select{width:190px; border:1px solid #ccc; height:25px; padding:2px;}
	</style>
	<script type="text/javascript">
		function chkfrm()
		{
			
			if($('#vip_c').val()=='')
			{
				$.messager.show({title:'提示',msg:'请输入会员号码',timeout:5000,showType:'slide'});
				return false;
			}
			if($('#card_c').val()=='')
			{
				$.messager.show({title:'提示',msg:'请输入购物卡号码',timeout:5000,showType:'slide'});
				return false;
			}
			if($('#check_card').val()!='1')
			{
				$.messager.show({title:'提示',msg:'购物卡号码不正确',timeout:5000,showType:'slide'});
				return false;
			}
			if($('#act_point').val()=='')
			{
				$.messager.show({title:'提示',msg:'请输入本次要使用的积分',timeout:5000,showType:'slide'});
				return false;
			}
			if(isNaN($('#act_point').val()))
			{
				$.messager.show({title:'提示',msg:'本次要使用的积分输入不正确',timeout:5000,showType:'slide'});
				return false;
			}
			if($('#act_amount').val()=='' || $('#act_amount').val()=='0' || isNaN($('#act_amount').val()))
			{
				$.messager.show({title:'提示',msg:'兑换金额不正确',timeout:5000,showType:'slide'});
				return false;
			}
			return true;
		}
		
		function get_card_amount()
		{
			var v_card_c = $('#card_c').val();
			if(v_card_c == '')
			{
				return false;
			}
			else
			{
				$.post("{:U('Shopcard/get_open_amount')}",{card_c:v_card_c},function(data,status){
					var data = eval("(" + data + ")");				
					var message = data.msg;
					var stkinfo = data.data;
					if(message=='ok')
					{
							$("#old_amount").attr("value",stkinfo.open_amount);
							$("#check_card").attr("value","1");
							return;
					}
					else
					{
						$.messager.show({title:'提示',msg:'错误：'+message,timeout:5000,showType:'slide'});
						return false;
					}
				});
			}
		}
		
		function cale_act_amount()
		{
			
			var act_point = $('#act_point').val();
			if(act_point=='')
			{
				$('#act_amount').attr('value','');
				return false;
			}
			else if(isNaN(act_point))
			{
				$.messager.show({title:'提示',msg:'本次要使用的积分输入不正确',timeout:5000,showType:'slide'});
				$('#act_amount').attr('value','');
				return false;
			}
			else if(parseFloat(act_point) > parseFloat($('#point').val()))
			{
				$.messager.show({title:'提示',msg:'使用的积分不能大于可用积分',timeout:5000,showType:'slide'});
				$('#act_amount').attr('value','');
				return false;
			}
			else
			{
				var point2card_rate = '{$point2card_rate}';
				var act_amount = parseFloat(act_point) * parseFloat(point2card_rate) / 100;
				$('#act_amount').attr('value',act_amount);
			}
		}
	</script>
</head>
<body class="">
	<div class="demo-info space-out-10px">
		<div class="demo-tip icon-tip"></div>
		<div>积分兑换购物卡</div>
	</div>
	<form id="form1" method="post" action="{:U('Vip/point_to_card_save')}" onsubmit="return chkfrm()">
	
	<ul class="idTabs space-out-10px"> 
		<li><a href="#tabs_basic">基本信息</a></li>
	</ul>
	<div id="tabs_basic">
		<table class="space-out-10px">
		<tr>
		<td style="width:100px;">会员号码：</td><td><input type="text" id="vip_c" name="vip_c" class="easyui-validatebox input" value="{$mydata.vip_c}" readonly required="true" /></td>
		</tr>
		
		<tr>
		<td>名称：</td><td><input type="text" id="title" name="title" class="easyui-validatebox input" value="{$mydata.title}" readonly required="true" /></td>
		</tr>
		
		
		<tr>
		<td>积分：</td><td><input type="text" id="point" name="point" class="input" value="{$mydata.point}" readonly /></td>
		</tr>
		
		<tr>
		<td colspan="2"><br/>--------------------------------------------------------------------------------------------------</td>
		</tr>		
		<tr>
		<td colspan="2">&nbsp;</td>
		</tr>
			
		
		<tr>
		<td>购物卡号码：</td><td><input type="text" id="card_c" name="card_c" class="input" value="" onchange="get_card_amount()"  /></td>
		</tr>
		
		<tr>
		<td>当前余额：</td><td><input type="text" id="old_amount" name="old_amount" class="input" value="" readonly /></td>
		</tr>
		
		<tr>
		<td colspan="2"><br/>--------------------------------积分兑换金额比例：{$point2card_rate}%----------------------------------------</td>
		</tr>		
		<tr>
		<td colspan="2">&nbsp;</td>
		</tr>
		
		<tr>
		<td>使用积分：</td><td><input type="text" id="act_point" name="act_point" class="input" onchange="cale_act_amount()"  /></td>
		</tr>
		
		<tr>
		<td>积分兑换金额：</td><td><input type="text" id="act_amount" name="act_amount" class="input" value="" readonly /></td>
		</tr>
		
		
		</table>	

		
	</div>
	
	
		<table class="space-out-10px">
		<tr>
		<td>&nbsp;</td><td>&nbsp;</td>
		</tr>
		<tr>
		<td>&nbsp;</td><td>
		<input type="hidden" id="check_card" name="check_card" value="0" />
		<a href="javascript:;" class="easyui-linkbutton" iconCls="icon-save" onclick="$('#form1').submit();">保存</a>
		<a href="{:U('Vip/data_list')}" class="easyui-linkbutton" iconCls="icon-undo">取消</a>
		</td>
		</tr>
		</table>
		

	</form>

</body>
</html>
